import * as bcryptjs from "bcryptjs"
import { Injectable } from "@nestjs/common";

import { env } from '../../settings'


@Injectable()
export class BcryptService {
    //加密
    careatePassword(password: string): Promise<string> {
        const hashPassword = bcryptjs.hashSync(password, env.SALT_ROUND)
        return hashPassword;
    }

    //验证密码
    checkPassword(password: string, hash_password: string): Promise<boolean> {
        return bcryptjs.compareSync(password, hash_password)
    }
}
